home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8352 / 8352.xpi / chrome / greasefire.jar / content / test / test_picker.js < prev    next >
Text File  |  2009-01-06  |  1KB  |  42 lines

  1. /*
  2.  * Copyright (C) 2008 by Steve Krulewitz <skrulx@gmail.com>
  3.  * Licensed under GPLv2 or later, see file LICENSE in the xpi for details.
  4.  */
  5. const Cc = Components.classes;
  6. const Ci = Components.interfaces;
  7. const Cr = Components.results;
  8.  
  9. function runTest() {
  10.  
  11.   var gfs = Cc["@skrul.com/greasefire/service;1"]
  12.               .getService(Ci.gfIGreasefireService);
  13.  
  14.   var uri = newURI("http://www.google.com");
  15.   var results = gfs.search(uri);
  16.  
  17.   var params = Cc["@mozilla.org/embedcomp/dialogparam;1"]
  18.                  .createInstance(Ci.nsIDialogParamBlock);
  19.   var array = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
  20.   array.appendElement(results, false);
  21.   array.appendElement(uri, false);
  22.   params.objects = array;
  23.  
  24.   const ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]
  25.                .getService(Ci.nsIWindowWatcher);
  26.  
  27.   ww.openWindow(null,
  28.                 "chrome://greasefire/content/picker.xul",
  29.                 "_blank",
  30.                 "chrome,all,dialog,modal,dialog=no",
  31.                 params);
  32.  
  33.   return true;
  34. }
  35.  
  36. function newURI(spec) {
  37.   var ioService = Cc["@mozilla.org/network/io-service;1"].
  38.                   getService(Ci.nsIIOService);
  39.  
  40.   return ioService.newURI(spec, null, null);
  41. }
  42.